import sgmllib

class html_parser(sgmllib.SGMLParser):

    def parse(self, s):
        self.feed(s)
        self.close()

    def __init__(self, window, verbose=0):
        sgmllib.SGMLParser.__init__(self, verbose)
	self.window=window
	
    def start_scripttool(self, attributes):
	for option, content in attributes:
	    if (option=="window"):
		if (content=="maximized"):
		    self.window.show("maximized")
		elif (content=="fullscreen"):
		    self.window.show("fullscreen")
		else:
		    self.window.show("normal")
	    elif (option=="close"):
		self.window.close_window()
	    elif (option=="size"):
		values= content.split("x")
		self.window.set_size(int(values[0]),int(values[1]))
    
    #Useful if tag has a data... <scripttool> DATA </scripttool>
    #def handle_data(self, data):
	#if self.inside:
	    #print data
    #def end_scripttool(self):
	#self.inside=0

